
using System;
using System.Collections.Generic;
using BTKERP.Model;
using BTKERP.DAL.DataAccess;
using System;

namespace BTKERP.DAL
{
	#region UnitTypeDAL
	public class UnitTypeDAL : DBContext
	{
		public List<UnitType> GetAll()
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_UnitTypesSelectAll");
            return GetEntityList<UnitType>(cmd);
        }

        public UnitType GetById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_UnitTypeSelect");
            cmd.AddParameter("@Id", id);
            return GetSingleEntity<UnitType>(cmd);
        }

		public List<UnitType> GetByDynamicSQL(string sqlCondition)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_UnitTypeSelectDynamic");
            cmd.AddParameter("@SQL", sqlCondition);
            return GetEntityList<UnitType>(cmd);
        }

        public UnitType Add(string paramName, string paramDescriptin, string paramCreatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_UnitTypeInsert");
            cmd.AddParameter("@Name", paramName);
            cmd.AddParameter("@Descriptin", paramDescriptin);
            cmd.AddParameter("@CreatedBy", paramCreatedBy);
            return GetSingleEntity<UnitType>(cmd);
        }

        public bool DeleteById(Guid id)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_UnitTypeDelete");
            cmd.AddParameter("@Id", id);
            return ExecuteCommand(cmd);
        }

        public UnitType UpdateById(Guid paramId, string paramName, string paramDescriptin, string paramUpdatedBy)
        {
            ExSQLCommand cmd = new ExSQLCommand("usp_UnitTypeUpdate");
			cmd.AddParameter("@Id", paramId);
			cmd.AddParameter("@Name", paramName);
			cmd.AddParameter("@Descriptin", paramDescriptin);
			cmd.AddParameter("@UpdatedBy", paramUpdatedBy);
            return GetSingleEntity<UnitType>(cmd);
        }
		
	}
	#endregion
}
